<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" @formChange="formChangeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <multiuse-button type="primary" :click="saveHandle">确 定</multiuse-button>
      <el-button @click="closeDialog">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { stockOut } from '@/api/dealerSale/SalesSanagement/RetailOrderMaintenance';

export default {
  mixins: [dictionary],
  props: {
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom()
    };
  },
  mounted() {},
  methods: {
    formChangeHandle(val) {
      this.saveData = val;
    },
    // 保存
    async saveHandle() {
      this.$refs.formPanel.SUBMIT_FORM();
      if (this.saveData !== null) {
        let saveData = Object.assign({}, this.rowData, this.saveData);
        console.log(saveData, '---保存的数据---');
        let res = await stockOut(saveData);
        if (res.resultCode === 200) {
          await this.closeDialog('refresh');
        }
      }
    },
    closeDialog() {
      this.$emit('close', false, 'refresh');
    },
    createdFrom() {
      return [
        {
          type: 'INPUT_NUMBER',
          label: '交车里程',
          fieldName: 'deliveryMileage',
          selfCols: 2,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        }
      ];
    }
  }
};
</script>
